package edu.ctbu.insurance.controller;

import com.github.pagehelper.PageInfo;
import edu.ctbu.insurance.bean.Claim;
import edu.ctbu.insurance.service.ClaimService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author djl
 * @since 2024-06-28
 */
@RestController
@RequestMapping("/claim")
public class ClaimController {
    @Autowired
    private ClaimService claimService;

    /**
     * 查询所有理赔信息
     */
    @RequestMapping("/findAllClaim")
    public PageInfo findAllClaim(int pageNum, int pageSize) {
        List<Claim> claimList = claimService.findAllClaim(pageNum, pageSize);

        return new PageInfo(claimList);
    }

    /**
     * 根据理赔ID和保单ID进行模糊查询
     * @param claimId 理赔ID
     * @param policyId 保单ID
     */
    @RequestMapping("/findAllClaimLikeClaimIdAndPolicyId")
    public PageInfo findAllClaimLikeClaimIdAndPolicyId(String claimId, String policyId, int pageNum, int pageSize) {
        List<Claim> claimList = claimService.findAllClaimLikeClaimIdAndPolicyId(claimId, policyId, pageNum, pageSize);

        return new PageInfo(claimList);
    }

    @RequestMapping("/updatePassClaimStatusAndSteps")
    public void updatePassClaimStatusAndSteps(String claimId) {
        claimService.updatePassClaimStatusAndSteps(claimId);
    }

    @RequestMapping("/updateRejectClaimStatusAndSteps")
    public void updateRejectClaimStatusAndSteps(String claimId) {
        claimService.updateRejectClaimStatusAndSteps(claimId);
    }
}
